package cn.yxsm.yxmall.controller;
import cn.yxsm.yxmall.mapper.BrandMapper;
import cn.yxsm.yxmall.pojo.entity.Brand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/brand")
public class BrandController {
    @Autowired(required = false)
    BrandMapper mapper;

    @RequestMapping("/insert")
    public List<Brand> insert(String name) {
        mapper.insert(name);
        return mapper.select();
    }

    @RequestMapping("select")
    public List<Brand> select() {
        return mapper.select();
    }

    @RequestMapping("delete")
    public void delete(int id) {
        mapper.deleteById(id);
    }
    @RequestMapping("/update")
    public void update(@RequestBody Brand brand){
        mapper.update(brand);
    }
    @RequestMapping("/deleteSelectAllBrands")
    public List<Brand> deleteSelectAllBrands(@RequestBody ArrayList<Integer> ids){
        System.out.println("ids = " + ids);
        mapper.deleteSelectAllBrands(ids);
        return mapper.select();

    }
}
